def compute_checksum2(iph):
    checksum = 0
    header_words = [iph[i:i+2] for i in range(0, len(iph), 2)]
    
    # Calculate the sum of all words without ntohs conversion
    for word in header_words:
        print('zzzzzzz=', int.from_bytes(word, byteorder='big'))
        checksum += int.from_bytes(word, byteorder='big')
    
    # Add carry (if any)
    while (checksum >> 16):
        checksum = (checksum & 0xFFFF) + (checksum >> 16)
        
    # One's complement
    return ~checksum & 0xFFFF

# Given IPHeader values for compute_checksum2
header_values2 = {
    'version': 4,
    'ihl': 5,
    'tos': 0,
    'total_length': 60,
    'identification': 49963,
    'fragoff': 0x4000,
    'ttl': 64,
    'protocol': 6,
    'checksum': 0,
    'src_ip': 0x7f000001,
    'dst_ip': 0x7f000001
}
print("{:04x}".format(header_values2['total_length']))
print(header_values2['total_length'].to_bytes(2, byteorder='big'))

print("{:04x}".format(header_values2['src_ip']))
print(header_values2['src_ip'].to_bytes(4, byteorder='big'))

# Pack the header values into a byte string (similar to C struct packing)
header2 = (
    (header_values2['version'] << 4 | header_values2['ihl']).to_bytes(1, byteorder='big') +
    header_values2['tos'].to_bytes(1, byteorder='big') +
    header_values2['total_length'].to_bytes(2, byteorder='big') +
    header_values2['identification'].to_bytes(2, byteorder='big') +
    header_values2['fragoff'].to_bytes(2, byteorder='big') +
    header_values2['ttl'].to_bytes(1, byteorder='big') +
    header_values2['protocol'].to_bytes(1, byteorder='big') +
    header_values2['checksum'].to_bytes(2, byteorder='big') +
    header_values2['src_ip'].to_bytes(4, byteorder='big') +
    header_values2['dst_ip'].to_bytes(4, byteorder='big')
)

# Compute the checksum using the modified C-style algorithm
csum2 = compute_checksum2(header2)
print(csum2)
